package com.hcloud.libupload.http

import com.hcloud.libupload.bean.FastUploadRes
import com.hcloud.libupload.bean.Res
import com.hcloud.libupload.comom.UploadLib
import com.hcloud.libupload.utils.UploadUtils
import okhttp3.RequestBody
import retrofit2.Call
import retrofit2.http.*

interface UploadApi {

    //快传
    @FormUrlEncoded
    @POST("webdav/fastUpload.do")
    fun fastUpload(
        @Field("loginkey") loginkey: String = "",
        @Field("boxId") boxId: String = "",
        @Field("requestId") requestId: String = UploadUtils.getRequestId(),
        @Field("filename") filename: String = "",
        @Field("parentPath") parentPath: String = "",
        @Field("filetype") filetype: String = "",//0 文件夹 1 图片 2视频 3音频 4 文档 5 其他
        @Field("size") size: Long = 0L,
        @Field("hash") hash: String = "",
        @Field("uploadType") uploadType: Int = 0,
        @Field("lastmod") lastmod: String = System.currentTimeMillis().toString(),
        @Field("serverType") serverType: String = "1",
        @QueryMap options: Map<String, String> = mapOf()
    ): Call<FastUploadRes>


    //上传文件
    @PUT
    fun commonUpload(
        @Header("Authorization") authorization: String = "",
        @Header("Upload-Total-Size") totalSize: String = "",
        @Header("Upload-Length") length: String = "",
        @Header("Upload-Start") start: String = "0",
        @Header("Upload-Id") uploadId: String = "",
        @Header("Upload-Name") name: String = "",
        @Header("Upload-User-Path") path: String = "",
        @Header("Upload-Filetype") fileType: String = "1",//0 文件夹 1 图片 2视频 3音频 4 文档 5 其他 6 cad(.dwg)
        @Header("Upload-Type") uploadType: String = "0",  //0 普通上传 1备份上传
        @Header("File-Hash") hash: String = "",
        @Header("Upload-Lastmod") lastmod: String = System.currentTimeMillis().toString(),
        @Header("Put-Type") putType: String = "Resume",
        @Header("Album-Name") album: String = "",
        @Header("Backup-BackupImageUUID") backupImageUuid: String = "",
        @Header("Backup-BackupVideoUUID") backupVideoUuid: String = "",
        @Header("Backup-LatestBackupImageTs") backupImageTs: String = "",
        @Header("Backup-LatestBackupVideoTs") backupVideoTs: String = "",
        @Header("Backup-Filetype") backupFileType: String = "",//0图片 1视频
        @Header("Backup-Id") backupId: String = "",
        @Header("Backup-ModificationDate") backupLastTime: String = "",
        @Header("longitude") longitude : Double = 0.0,
        @Header("latitude") latitude : Double = 0.0,
        @Url url: String = "",
        @Body requestBody: RequestBody
    ): Call<Any>


    @POST("openapi/upload/status")
    fun status(
        @Header("Authorization") auth: String = UploadLib.instance().uploadAuth,
        @Body reqBody: RequestBody
    ): Call<Res>

    @POST("openapi/upload/register")
    fun register(
        @Header("Authorization") auth: String = UploadLib.instance().uploadAuth,
        @Body reqBody: RequestBody
    ): Call<Res>

    @PUT("openapi/upload/data")
    fun upload(
        @Header("Authorization") auth: String = UploadLib.instance().uploadAuth,
        @Header("wo-uploadId") uploadId: String = "",
        @Header("wo-partStart") partStart: String = "",
        @Header("wo-partSize") partSize: String = "",
        @Body requestBody: RequestBody
    ): Call<Res>

    @POST("openapi/upload/complete")
    fun complete(
        @Header("Authorization") auth: String = UploadLib.instance().uploadAuth,
        @Body reqBody: RequestBody
    ): Call<Res>

}